//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    // tab切换  
    currentTab: 0, 
  },
  onLoad: function () {
    var that = this;

    /** 
     * 获取系统信息 
     */
    wx.getSystemInfo({

      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight
        });
      }

    });
  },  
  
  /** 
   * 点击tab切换 
   */
  swichNav: function (e) {

    var that = this;

    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  },  

  /** 
     * 滑动切换tab 
     */  
  bindChange: function (e) {

    var that = this;
    that.setData({ currentTab: e.detail.current });

  }, 

  
  getOpenIdTap: function () {
    console.log(1111);
    var that = this;
    wx.login({
      success: function (res) {
        console.log(res.code)
        wx.request({
          //获取openid接口  
          url: 'https://wechat.gcclib.com/home/Question/userinfo',
          data: {
            code: res.code,
            wechat_id:123456
          },
          method: 'GET',
          success: function (res) {
            console.log(res.data.res)
            var openid = res.data.res

          }
        })
      }
    })
  }  
})
